package packing;

import java.util.ArrayList;
import java.util.List;


public class BoxInput extends BoxPressure implements Comparable<BoxInput>{
	
	private int id;
	private boolean xRotation;
	private boolean yRotation;
	private boolean zRotation;
	private int quantity;
	public BoxInput(int width, int length, int height, int weight, int pressure) {
		super(width, length, height, weight, pressure);

	}

	public BoxInput(int id,int width,boolean xRotation, int length,boolean yRotation,
			int height, boolean zRotation, int quantity, int weight, int pressure) {
		super(width, length, height, weight, pressure);
		this.id = id;
		this.xRotation = xRotation;
		this.yRotation = yRotation;
		this.zRotation = zRotation;
		this.quantity = quantity;
	}
	public BoxInput copy(){
		return new BoxInput(this.id, this.width, this.xRotation, this.length, this.yRotation, this.height, this.zRotation, this.quantity, this.weight, this.pressure);
	}
	
	public int getRotation(){
		int rotation =0;
		if(xRotation) rotation++;
		if(yRotation) rotation++;
		if(zRotation) rotation++;
		return rotation;
		
	}

	@Override
	public String toString() {
//		return "BoxInput [id=" + id + ", quantity=" + quantity + ", xRotation="
//				+ xRotation + ", yRotation=" + yRotation + ", zRotation="
//				+ zRotation + "]\n";		
		return "BoxInput : หมายเลขกล่อง = "+id+" (กว้าง : "+width+" x ยาว : "+length+" x สูง : "+height+" ) จำนวน = "+quantity+" กล่อง ( xRotation ="
				+ xRotation + ", yRotation =" + yRotation + ", zRotation ="
				+ zRotation + ", น้ำหนัก ="+weight+", การรับแรงกดทับ="+pressure+" ) ";
	}

	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public boolean isxRotation() {
		return xRotation;
	}

	public void setxRotation(boolean xRotation) {
		this.xRotation = xRotation;
	}

	public boolean isyRotation() {
		return yRotation;
	}

	public void setyRotation(boolean yRotation) {
		this.yRotation = yRotation;
	}

	public boolean iszRotation() {
		return zRotation;
	}

	public void setzRotation(boolean zRotation) {
		this.zRotation = zRotation;
	}

	@Override
	public int compareTo(BoxInput o) {
		if(this.getId() <o.getId()){
			return -1;
		}else if(this.getId() >o.getId()){
			return 1;
		}
			
		return 0;
	}
	
	
	public List<BoxPack> getBoxPackList(){
		List<BoxPack> boxPackList = new ArrayList<BoxPack>();
		boxPackList.add(new BoxPack(this.id,this.width, this.length, this.height, this.weight, this.pressure));
		
		if(xRotation){

			boxPackList.add(new BoxPack(this.id, this.width,this.height,this.length, this.weight, this.pressure));
		}
		if(yRotation){
			boxPackList.add(new BoxPack(this.id,this.height, this.length, this.width, this.weight, this.pressure));
		}
		
		if(zRotation){

			boxPackList.add(new BoxPack(this.id, this.length, this.width,this.height, this.weight, this.pressure));
		}
		if(xRotation && yRotation){
			boxPackList.add(new BoxPack(this.id, this.length,this.height,this.width, this.weight, this.pressure));
			boxPackList.add(new BoxPack(this.id, this.height,this.width,this.length, this.weight, this.pressure));
			
		}
		if(xRotation && zRotation){
			boxPackList.add(new BoxPack(this.id, this.height,this.width,this.length, this.weight, this.pressure));
			boxPackList.add(new BoxPack(this.id, this.length,this.height,this.width, this.weight, this.pressure));
			
		}
		if(yRotation && zRotation){
			boxPackList.add(new BoxPack(this.id, this.length,this.height,this.width, this.weight, this.pressure));
			boxPackList.add(new BoxPack(this.id, this.height,this.width,this.length, this.weight, this.pressure));
		}
		return boxPackList;
	}
	public int minusOne(){
		this.quantity = this.quantity -1;
		return this.quantity;
	}
	public int minus(int dededuction){
		this.quantity = this.quantity -dededuction;
		return this.quantity;
	}
	public int plusOne(){
		this.quantity = this.quantity +1;
		return this.quantity;
	}
	public int plus(int increasement){
		this.quantity = this.quantity +increasement;
		return this.quantity;
	}

	
	



}
